package main

import "fmt"

func main() {
	n := 5
	var sn []int
	for i := 0; i < n; i++ {
		sn = append(sn, i+1)
	}
	DG(sn, 0, n)
}

func DG(i []int, id, n int) {
	if id == n-1 {
		for a := 0; a < n; a++ {
			fmt.Print(i[a], "\t")
		}
		fmt.Println()
	} else {
		for a := id; a < n; a++ {
			i[a], i[id] = i[id], i[a]
			DG(i, id+1, n)
			i[a], i[id] = i[id], i[a]
		}
	}
}
